{extend name="public:base"/}
{block name="style"}

{/block}
{block name="main"}

<form class="layui-form" action="" method="POST" >
  <div class="layui-form-item">
    <label class="layui-form-label">模型名称</label>
    <div class="layui-input-block  width-350">
      <input type="hidden" name="modelid" value="{$info['modelid']}">
      <input type="text" name="name" lay-verify="required"  placeholder="请输入模型名称" autocomplete="off" class="layui-input" value="{$info['name']}">
    </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">类型</label>
      <div class="layui-input-block width-350" >
        <select name="type" lay-verify="required"  lay-filter="test" id="type" >
          <option value="">请选择类型</option>
          <option value="列表类型" {if condition="$info['type'] eq '列表类型'"}selected {/if}>列表类型</option>
          <option value="单页类型" {if condition="$info['type'] eq '单页类型'"}selected {/if}>单页类型</option>
            
        </select>   
      </div>
  </div>
  
  <!-- 单页模板列表 -->
  <div class="layui-form-item selectlist" id="templatepage" style="display:none;{if condition="$info['type'] eq '单页类型'"}display:block;{/if}">
      <label class="layui-form-label">单页模板</label>
      <div class="layui-input-block width-350" >
        <select name="template[0]">
         
          <option value="">请选择模板</option>
          {foreach $pages[0] as $v}
              <option value="{$v}" {if condition="$v eq $info['template'][0]"}selected{/if}>{$v}.html</option>
          {/foreach}
        </select>   
      </div>
  </div>

  <div class="layui-form-item selectlist"  id="templatelist" style="display:none;{if condition="$info['type'] eq '列表类型'"}display:block;{/if}">
      <label class="layui-form-label">列表页</label>
      <div class="layui-input-inline width-350" >
        <select name="template[1]" >
          <option value="">请选择模板</option>
          {foreach $pages[1] as $v}
              <option value="{$v}" {if condition="$v eq $info['template'][0]"}selected{/if}>{$v}.html</option>
          {/foreach}
        </select>   
      </div>
      <label class="layui-form-label">内容页</label>
      <div class="layui-input-inline width-350" >
        <select name="template[2]" >
          <option value="">请选择模板</option>
          {foreach $pages[2] as $v}
              <option value="{$v}" {if condition="$v eq $info['template'][1]"}selected{/if}>{$v}.html</option>
          {/foreach}
        </select>   
      </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-inline width-350">
      <input type="number" name="px"  placeholder="请输入数字排序" autocomplete="off" class="layui-input" value="{$info['px']}">
    </div>
  </div>

  <!-- <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      <input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" lay-filter="switchTest" value="1" {if condition="($info['status'] eq '1') OR ($info['status'] neq '0')"}checked=''{/if}>
      <div class="layui-unselect layui-form-switch" lay-skin="_switch">
        <em>OFF</em><i></i>
      </div>
    </div>
  </div> -->

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

<script type="text/javascript">
	layui.use(['form'], function(){
	  var form = layui.form;

    form.on('select(test)', function(data){

      $(".selectlist").hide();
      if(data.value=='单页类型'){
        $("#templatepage").show();  
      }else if(data.value=='列表类型'){
        $("#templatelist").show();
      }
     
    });  

    layer.photos({
      photos: 'div'
      ,anim: 5 
    }); 

	  form.verify({
	    title: function(value){
	      if(value.length < 1){
	        return '标题至少得1个字符';
	      }
	    }
	  });
	});
</script>

{/block}